import { t, useI18n } from '@/hooks/web/useI18n'
import { getResActBtns } from '@/api/res/ResCenter/ResActBtns'

export enum BizIconTypes {
  font,
  svg
}

const actBtns = getResActBtns()

/**
 * 默认图标样式
 * @type {{color: string, name: string, className: string, label: string, type: number}}
 */
export const BizIconPropDefault = {
  type: BizIconTypes.font,
  name: 'caiwu',
  label: '财务',
  className: 'iconfont iconicon_work'
}

// 定义属性对象
export const ResourceAttr = {
  Resource: {
    label: '资源',
    value: 1,
    icon: BizIconPropDefault,
    actBtn: [
      // actBtns.addSubItem,
      // actBtns.resourceDesigner,
      // actBtns.copy,
      // actBtns.appDeploy
    ]
    // viewCmb: () => import('@/components/resource/resView/ResSelf.vue')
  },
  // Tenant: { label: '租户', value: 2 },
  // Platform: { label: '平台', value: 3 },
  // Org: { label: '组织', value: 10 },
  // User: { label: '用户', value: 11 },
  // Role: { label: '角色', value: 12 },
  // Post: { label: '岗位', value: 13 },
  // Menu: { label: '菜单', value: 20 },
  // Dict: { label: '字典', value: 21 },
  App: {
    label: '应用',
    value: 100,
    icon: {
      type: BizIconTypes.font,
      name: 'caiwu',
      label: '财务',
      className: 'iconfont icon-caiwu'
    },
    actBtn: [actBtns.appDesigner, actBtns.appDeploy]
    // viewCmb: () => import('@/components/resource/resView/ResAppView.vue')
  },
  Form: {
    label: '表单',
    value: 101,
    icon: {
      type: BizIconTypes.font,
      name: 'caiwu',
      label: '财务',
      className: 'iconfont icon-caiwu'
    },
    actBtn: [actBtns.formDesigner, actBtns.formFillOut, actBtns.formDataList]
    // viewCmb: () => import('@/components/resource/resView/ResFormView.vue')
  },
  Process: {
    label: '审批',
    value: 102,
    icon: {
      type: BizIconTypes.font,
      name: 'caiwu',
      label: '财务',
      className: 'iconfont icon-caiwu'
    },
    actBtn: [actBtns.designer, actBtns.preview, actBtns.auth, actBtns.more]
    // viewCmb: () => import('@/components/resource/resView/ResApprovalView.vue')
  },
  Page: {
    label: '页面',
    value: 109,
    icon: {
      type: BizIconTypes.font,
      name: 'caiwu',
      label: '财务',
      className: 'iconfont icon-caiwu'
    },
    actBtn: [actBtns.pageDesigner]
    // viewCmb: () => import('@/components/resource/resView/ResPageView.vue')
  },
  FormProcess: {
    label: '表单流程',
    value: 103
    // viewCmb: () => import('@/components/resource/resView/ResFormProcessView.vue')
  },
  Table: {
    label: '表格',
    value: 104,
    icon: {
      type: BizIconTypes.font,
      name: 'caiwu',
      label: '财务',
      className: 'iconfont icon-caiwu'
    }
    // viewCmb: () => import('@/components/resource/resView/ResTableView.vue')
  },
  Dashboard: {
    label: '仪表',
    value: 105,
    icon: {
      type: BizIconTypes.font,
      name: 'caiwu',
      label: '财务',
      className: 'iconfont icon-caiwu'
    },
    actBtn: [actBtns.dashboardDesigner]
    // viewCmb: () => import('@/components/resource/resView/ResDashboardView.vue')
  },
  Portal: {
    label: '自定义门户',
    value: 106,
    icon: {
      type: BizIconTypes.font,
      name: 'caiwu',
      label: '财务',
      className: 'iconfont icon-caiwu'
    }
    // viewCmb: () => import('@/components/resource/resView/ResPortalView.vue')
  },
  Report: {
    label: '报表',
    value: 107,
    icon: {
      type: BizIconTypes.font,
      name: 'caiwu',
      label: '财务',
      className: 'iconfont icon-caiwu'
    }
    // viewCmb: () => import('@/components/resource/resView/ResReportView.vue')
  },
  kb: {
    label: '知识库',
    value: 108,
    icon: {
      type: BizIconTypes.font,
      name: 'caiwu',
      label: '财务',
      className: 'iconfont icon-caiwu'
    }
    // viewCmb: () => import('@/components/resource/resView/ResKbView.vue')
  },
  AutoFlow: {
    label: '自动化流程',
    value: 111,
    icon: {
      type: BizIconTypes.font,
      name: 'caiwu',
      label: '财务',
      className: 'iconfont icon-caiwu'
    }
    // viewCmb: () => import('@/components/resource/resView/ResAutoFlowView.vue')
  },
  file: {
    label: '自动化流程',
    value: 112,
    icon: {
      type: BizIconTypes.font,
      name: 'caiwu',
      label: '财务',
      className: 'iconfont icon-caiwu'
    }
    // viewCmb: () => import('@/components/resource/resView/ResAutoFlowView.vue')
  }
  , api: {
    label: '接口',
    value: 113,
    icon: {
      type: BizIconTypes.font,
      name: 'caiwu',
      label: '财务',
      className: 'iconfont icon-caiwu'
    },
    actBtn: [actBtns.apiDesigner]
    // viewCmb: () => import('@/components/resource/resView/ResPageView.vue')
  },
}

export class ResourceAttrUtil {
  static getResAttrByCategory(category: number | string): any {
    const attr = Object.values(ResourceAttr).find((item) => item.value === category)
    return attr || ResourceAttr.Resource
  }
}

export const ResourceTypesDicData = Object.values(ResourceAttr).map((m) => {
  return {
    label: m.label,
    value: m.value
  }
})
